var oMenu = $('.menu');
var oLogo = $('.logo');
var oCore = $('.core');
var oNotice=$('.onotice');
var oScaling = $('#scaling');
var oLeft = $('.left');
var oARight = $('.a-right');
var oRight = $('.right');
var oLogoImg = $('.logo img');
var oTable=$('.table1');
var oPass=$('.pass');
var getName = JSON.parse(localStorage.getItem('loginUser')).name;
var getJurisdiction = JSON.parse(localStorage.getItem('staff'));
var getStu=JSON.parse(localStorage.getItem('studentJson'));





oPass.on('click',function () {
    alert('权限不足，请联系超级管理员修改！')
})
//搜索
$('.con').on('click',function () {
    var SearchName=$('#Search').val();
    oTable.html('');
    oTable.append('<tr style="font-size:larger; border-bottom:3.5px solid #dee2e6 ;border-top: 2px solid #dee2e6 ;"><th>' +'没有搜到相关内容！'+ '</th></tr>');
    $.each(getStu, function (index, value) {
        if (SearchName == value.name||SearchName ==value.id) {
            oTable.html('');
            oTable.append(
                '<tr style="font-size: 14px; border-bottom:3.5px solid #dee2e6 ;border-top: 2px solid #dee2e6 ;"><th>' +'姓名'
                + '</th><th>' + '性别'
                + '</th><th>' + '班级'
                + '</th><th>' + '生日'
                + '</th><th>' + '监护人'
                + '</th><th>' + '电话'
                + '</th><th>' + '家庭住址'
                + '</th></tr><tr class="checkList"><td>' + value.name
                + '</td><td>' + value.sex
                + '</td><td>' + value.class
                + '</td><td>' + value.birth
                + '</td><td>' + value.parent
                + '</td><td>' + value.phone
                + '</td><td>' + value.address
                + '</td></tr>')


        }


    });
    $.each(getJurisdiction, function (index, value) {
        if (SearchName == value.name||SearchName ==value.Jn) {
            oTable.html('');
            oTable.append(
                '<tr style="font-size: 14px; border-bottom:3.5px solid #dee2e6 ;border-top: 2px solid #dee2e6 ;"><th>' +'姓名'
                + '</th><th>' + '部门'
                + '</th><th>' + '职位'
                + '</th><th>' + '性别'
                + '</th><th>' + '出生日期'
                + '</th><th>' + '联系方式'
                + '</th></tr><tr class="checkList"><td>' + value.name
                + '</td><td>' + value.department
                + '</td><td>' + value.post
                + '</td><td>' + value.sex
                + '</td><td>' + value.birthday
                + '</td><td>' + value.Tel
                + '</td></tr>')

        }

    });

});



function s() {
    $.each(getJurisdiction, function (index, value) {
        if (getName == value.name) {
            for (var key in value.paimanage) {
                if (!value.paimanage[key]) {
                    $('.' + key + '').css('display', 'none')
                }
            }
            $('.head-portrait').attr('src',value.src)


        }


    });
    $('#uname').text(getName);

}
s();
oScaling.on('click', function () {
    if (oLeft.css('width') == '240px') {
        oARight.css("display", "none");
        oLeft.css('width', '110px');
        oRight.css('margin-left', '110px');
        oLogoImg.css('margin-left', '0');
        oMenu.on('click', 'a', function () {
            $(this).css("color", "white");
            $(this).parent().siblings().children().css("color", "#7e8cda");
        });
        oLogo.on('click', function () {
            oMenu.children('li').children('a').css("color", "#7e8cda");
            oMenu.children(':first').children(':first').css("color", "white");

        });
        oCore.on('click', function () {
            oMenu.children('li').children('a').css("color", "#7e8cda");
            oMenu.children('li').eq(1).children(':first').css("color", "white");

        });
        oNotice.on('click', function () {
            oMenu.children('li').children('a').css("color", "#7e8cda");
            oMenu.children('li').eq(7).children(':first').css("color", "white");

        });
    } else {
        oARight.css("display", "inline-block");
        oLeft.css('width', '240px');
        oRight.css('margin-left', '240px');
        oLogoImg.css('margin-left', '65px');

    }
});
oMenu.on('click', 'a', function () {
    if (oLeft.css('width') == '240px') {
        $(this).children('.a-right').css("display", "none");
        $(this).parent().siblings().children().children('.a-right').css("display", "inline-block");
        $(this).css("color", "white");
        $(this).parent().siblings().children().css("color", "#7e8cda");
    }

});
oLogo.on('click', function () {
    if (oLeft.css('width') == '240px') {
        oMenu.children('li').children('a').children('.a-right').css("display", "inline-block");
        oMenu.children('li').children('a').css("color", "#7e8cda");
        oMenu.children(':first').children(':first').children('.a-right').css("display", "none");
        oMenu.children(':first').children(':first').css("color", "white");
    }
});
oCore.on('click', function () {
    if (oLeft.css('width') == '240px') {
        oMenu.children('li').children('a').children('.a-right').css("display", "inline-block");
        oMenu.children('li').children('a').css("color", "#7e8cda");
        oMenu.children('li').eq(1).children(':first').children('.a-right').css("display", "none");
        oMenu.children('li').eq(1).children(':first').css("color", "white");
    }
});
oNotice.on('click', function () {
    if (oLeft.css('width') == '240px') {
        oMenu.children('li').children('a').children('.a-right').css("display", "inline-block");
        oMenu.children('li').children('a').css("color", "#7e8cda");
        oMenu.children('li').eq(7).children(':first').children('.a-right').css("display", "none");
        oMenu.children('li').eq(7).children(':first').css("color", "white");
    }
});